$(function(){
	$("#submitBtn").button();
	$("#backBtn" ).button({
		text: false,
		icons: {
			primary: "ui-icon-arrowreturnthick-1-w"
		}
	}).click(back);
	$("#user").validate({
		debug:true,
		rules: {
			'user.loginId': {
				required:function(){return $("#loginId")!='undefine';},
				rangelength:[6,20],
				remote:{
					url: "register!validateLoginIdUserful.do",     //后台处理程序     
		            type: "post",               //数据发送方式     
		            dataType: "json",           //接受数据格式        
	            	data: {               //要传递的数据，默认已传递应用此规则的表单项     
	            		loginId: function() {
	                    	return $("#loginId").val();     
	                	}
					}
				}
			},
			'user.password': {
				required:function(){return $("#password")!='undefine';},
				alphanumeric:'',
				rangelength:[6,30]
			},
			'password2': {
				required:function(){return $("#password2")!='undefine';},
				equalTo:'#password'
			},
			'user.nickName': {
				required:true,
				maxlength:25
			},
			'user.realName': {
				maxlength:25
			},
			'user.email': {
				maxlength:50
			}
		},
		messages: {
			'user.loginId': {
				required:'请输入登录名',
				letterswithbasicpunc:'输入的内容只能为字母或符号的组合',
				remote:'该登录名已经存在，请换一个'
			},
			'user.password': {
				required:'请输入登录密码',
				alphanumeric:'输入的内容必须为字母、数字或其组合'
			},
			'password2': {
				required:'请再次输入登录密码',
				equalTo:'请确认两次输入的密码一致'
			},
			'user.nickName': {
				required:'请输入用户昵称'
			}
		},
		submitHandler:function(form){
			$("#formContainer").block({ message: '<h3><img src="../images/icon/loading.gif" />正在提交用户信息……</h3>' });
			form.submit();
		}
	});
});